package com.common.enums;

import com.fasterxml.jackson.annotation.JsonInclude;

/**
 * 结果返回类
 */
public class ApiResult {

    private String status;

    private String msg;

    private Object data;

    public ApiResult(String status, String msg, Object data) {
        this.status = status;
        this.msg = msg;
        this.data = data;
    }

    public static ApiResult success(Object data) {
        return new ApiResult(ResultEnum.SUCCESS.getCode(), ResultEnum.SUCCESS.getMsg(), data);
    }

    public static ApiResult success() {
        return new ApiResult(ResultEnum.SUCCESS.getCode(), ResultEnum.SUCCESS.getMsg(), null);
    }

    public static ApiResult failure(Object data) {
        return new ApiResult(ResultEnum.FAILURE.getCode(), ResultEnum.FAILURE.getMsg(), data);
    }

    public static ApiResult failure(String msg) {
        return new ApiResult(ResultEnum.FAILURE.getCode(), msg, null);
    }

    public static ApiResult failure(String msg,Object data) {
        return new ApiResult(ResultEnum.FAILURE.getCode(), msg, data);
    }

    public static ApiResult failure() {
        return new ApiResult(ResultEnum.FAILURE.getCode(), ResultEnum.FAILURE.getMsg(), null);
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
